package br.com.wepa.webapps.orca.logica.modelo;

// Generated 12/01/2007 02:01:35 by Hibernate Tools 3.2.0.beta8

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Credencial generated by hbm2java
 */
@Entity
@Table(name = "credencial", catalog = "Orca", uniqueConstraints = {})
public class Credencial implements java.io.Serializable {

	// Fields    
/**
	 * 
	 */
	private static final long serialVersionUID = 7261482645269236602L;
	
	private int idCredencial;

	private String nome;

	private Set<Usuario> usuarios = new HashSet<Usuario>(0);

	private Set<Funcao> funcaos = new HashSet<Funcao>(0);

	// Constructors

	/** default constructor */
	public Credencial() {
	}

	/** minimal constructor */
	public Credencial(int idCredencial, String nome) {
		this.idCredencial = idCredencial;
		this.nome = nome;
	}

	/** full constructor */
	public Credencial(int idCredencial, String nome, Set<Usuario> usuarios,
			Set<Funcao> funcaos) {
		this.idCredencial = idCredencial;
		this.nome = nome;
		this.usuarios = usuarios;
		this.funcaos = funcaos;
	}

	// Property accessors
	@Id
	@Column(name = "idCredencial", unique = true, nullable = false, insertable = true, updatable = true)
	public int getIdCredencial() {
		return this.idCredencial;
	}

	public void setIdCredencial(int idCredencial) {
		this.idCredencial = idCredencial;
	}

	@Column(name = "nome", unique = false, nullable = false, insertable = true, updatable = true)
	public String getNome() {
		return this.nome;
	}

	public void setNome(String nome) {
		this.nome = nome;
	}

	@OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY, mappedBy = "credencial")
	public Set<Usuario> getUsuarios() {
		return this.usuarios;
	}

	public void setUsuarios(Set<Usuario> usuarios) {
		this.usuarios = usuarios;
	}

	@ManyToMany(
	        targetEntity=br.com.wepa.webapps.orca.logica.modelo.Funcao.class,
	        cascade={CascadeType.REMOVE, CascadeType.MERGE}
	    )
    @JoinTable(
        name="Credencial_Funcao",
        joinColumns={@JoinColumn(name="Credencial_idCredencial")},
        inverseJoinColumns={@JoinColumn(name = "Funcao_idFuncao"),@JoinColumn(name = "Funcao_Modulo_idModulo")}
    )
	public Set<Funcao> getFuncaos() {
		return this.funcaos;
	}

	public void setFuncaos(Set<Funcao> funcaos) {
		this.funcaos = funcaos;
	}

}
